<?php
    class W_jurusan_mod extends Model{
        function W_jurusan_mod(){
            parent::Model();   $this->load->model('Datum_model'); 
        }
  
        
        function list_($where="", $num=0, $offset=0, $ro=false) {
            
            $this->db->from('jurusan');
             
            
            if ($where!='') {
                $this->db->where($where);
            }
            
            if ($num > 0) {
                $this->db->limit($num, $offset);
            }
            $query = $this->db->get();
            $s = "
              <table align=\"center\" cellspacing=\"1\" cellpadding=\"2\" class=\"tbl\">
                <tbody>
                  <tr>
                    <th class='number'>No</th>
                    <th>Jurusan</th>
                    
                                       
                    ";
            if ($ro==false) {
                $s .= " 
                        <th colspan='2'> Aksi </th>";
            }

            $s .= "</tr>
            ";
            if ($num > 0) {
                $i = ($num * ($offset/$num)) + 1;
            } else {
                $i = 1;
            }

            
            
            foreach ($query->result() as $row) {
                
                
                if ($i % 2 == 1 ) {
                    $kelas = "event2";
                } else {
                    $kelas = "event";
                }
               
               
                              
                $s .= "
              <tr class=\"$kelas\">
                
                <td><div align=\"right\">$i.</div></td>                
                <td><div>".$row->nama."</div></td>
                
                
                
                ";
                if ($ro==false) {
                    $s .= "
                    
                    <td><div align='center'> <a href='".base_url()."index.php/jurusan/edit_/".$row->idspg_jurusan."' title=\"Ubah Data\" class=\"edit\"><img src='".base_url()."images/edit.gif' border='0'></a></div></td>   
                    <td><div align='center'> <a href=\"javascript:deleteRow('".$row->idspg_jurusan."')\"><img src='".base_url()."images/del.gif' border='0'></a></div></td>";
                    
                }
                $s .= "
              </tr>";

                $i++;
            }
            $s .= "</table>";
            return $s;
        }

        
        function entry_($url,$nama='',$id=0) {
            
                       

            $ret = "<fieldset>
            <form id='jurusan' method='post' action='$url'>
              <table class=\"formTabel\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\">      
                  <tr>
                    <td class=\"kolom\" valign=\"top\">Nama Jurusan </td>
                    <td>:</td>
                    <td><input name='nama' id='nama' type='text' size='50' value='$nama' /><input name='id' id='id' type='hidden' size='15' value='$id' /></td>
                  </tr>
                  
                  
               <tr>
                    <td valign='top'>&nbsp;</td>
                    <td valign='top'>&nbsp;</td>
                    <td valign='top'>
                      <input class=\"tombol\" type=\"button\" name=\"btn_kembali\" id=\"btn_kembali\" value=\"<< Kembali\" />
                  <input class=\"tombol\" type=\"submit\" name=\"button\" id=\"button\" value=\"   Simpan   \" />
                     </td>
                  </tr>
                </table>
        
                </fieldset>

                </form>";
                return $ret;
        }
        
        function simpan($arr, $is_update=false, $id=0) {
         
              
    
            if ($is_update==FALSE) {
                $this->db->insert('jurusan', $arr);
            } else {
                $this->db->where("idspg_jurusan", $id);
                $this->db->update('jurusan', $arr);
            }
        }
        
        
        
        
    }
?>